package com.doit.demo01;

import javax.jnlp.IntegrationService;
import java.io.*;
import java.util.*;

public class test03 {
    public static void main(String[] args) throws IOException {
//        String s = "liuyan,38-tangyang,18-jinlian,138-dalang,8";
        BufferedReader br = new BufferedReader(new FileReader("day21\\aaa\\person.txt"));
        String s = br.readLine();

        String[] split = s.split("-");
        String[] pai = pai(split);
        FileWriter w = new FileWriter("day21\\aaa\\person.txt");
        for (int i = 0; i < pai.length; i++) {
            if(i!=pai.length-1)
                w.write(pai[i]+"-");
            else
                w.write(pai[i]);
            w.flush();

        }
        w.close();
        br.close();

    }
    private static String[] pai(String[] s){

        Arrays.sort(s, new Comparator<String>() {
            @Override
            public int compare(String o1, String o2) {
                String[] s1 = o1.split(",");
                String[] s2 = o2.split(",");
                return Integer.parseInt(s1[1])- Integer.parseInt(s2[1]);
            }
        });
        for (String s1 : s) {
            System.out.println(s1);
        }
        return s;
    }
}


